package cn.gson.fengboot.model.dao;


import cn.gson.fengboot.model.pojos.QmenusEntity;
import cn.gson.fengboot.model.pojos.Qrolesmenu;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface DrolesmenuDao extends CrudRepository<Qrolesmenu,Integer>{

    List<Qrolesmenu> findByRoleId(Integer roleId);

    @Transactional //必须添加这2个注解
    @Modifying   //必须添加这2个注解
    @Query(value="delete from qrolesmenu where role_id = ?1",nativeQuery = true)
    void deleteByRoleId(Integer roleId);


    @Query(value="select * from qrolesmenu r where r.role_id = ?1 and r.me_id = ?2",nativeQuery = true)
    Qrolesmenu findByRoleIdAndMeId(Integer roleId, Integer meId);



    @Transactional //必须添加这2个注解
    @Modifying   //必须添加这2个注解
    @Query(value="delete from qrolesmenu where role_id = ?1 and me_id = ?2",nativeQuery = true)
    void deleteByRoleIdAndMeId(Integer roleId,Integer meId);

}
